package condition;

import elements.Element;

/**
 * A class of binary composed conditions, representing the anding of the
 * two operands.
 * 
 * @version	3.0
 * @author 	Lies Tambeur 	r0264469	2Bcwsbbh
 * @author	Eline Vanrykel	r0264543	2Bcwselt
 *
 */
public class And extends BinaryComposedCondition {

	/**
	 * Initialize this new addition with given operands.
	 *
	 * @param  conditionOne
	 *         The first condition for this new And.
	 * @param  conditionTwo
	 *         The second condition for this new And.
	 * @effect This new And is initialized as a binary composed condition
	 *         with the given conditions.
	 */
	public And(Condition conditionOne, Condition conditionTwo) {
		super(conditionOne, conditionTwo);
	}
	
	/**
	 * Returns true if both conditions are met, and false when only one or none of the conditions are met.
	 */
	@Override
	public boolean evaluate(Element element) {
		return conditionOne.evaluate(element) && conditionTwo.evaluate(element);
	}

	@Override
	public String toString(){
		return "( and" + this.getFirstCondition().toString()  + this.getSecondCondition().toString() + " )";
	}
	
	@Override
	public boolean equals(Object object){
		if(object == null || this==null){
			return false;
		}
		return this.toString().equals(object.toString());
	}

}
